package com.lib.module_base.utils

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.text.TextUtils
import android.widget.Toast

object CopyUtil {

    fun copy(context: Context, text: String?, toast: String?) {
        if (TextUtils.isEmpty(text)) return
        val cmb = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
        cmb.setPrimaryClip(ClipData.newPlainText("text", text))
        if (!TextUtils.isEmpty(toast)) {
            Toast.makeText(context, toast, Toast.LENGTH_SHORT).show()
        }
    }
}